package com.antis.olsl.data.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import com.antis.olsl.data.R;
import com.antis.olsl.library.bean.AllocateSlipInfo;
import com.antis.olsl.library.utils.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.math.BigDecimal;
import java.util.List;

/**
 * @ProjectName: ATS_OLSL
 * @Package: com.antis.olsl.adapter
 * @ClassName: A_ExampleAdapter
 * @Description: 采购差异单列表
 * @Author: 羊琪
 * @CreateDate: 2020/3/30 19:58
 * @UpdateDate: 2020/3/30 19:58
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class AllocateSlipListAdapter extends BaseQuickAdapter<AllocateSlipInfo, BaseViewHolder> implements LoadMoreModule {
    public AllocateSlipListAdapter(List<AllocateSlipInfo> data) {
        super(R.layout.listitem_table, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AllocateSlipInfo item) {
        helper.setText(R.id.tv_1, item.getCreateTime())
                .setText(R.id.tv_2, item.getAllocateNumber().substring(0, 6) + "..." + item.getAllocateNumber().substring(item.getAllocateNumber().length() - 4))
                .setText(R.id.tv_3, !TextUtils.isEmpty(item.getInSalesroomName()) ? item.getInSalesroomName() : item.getInWarehouseName())
                .setText(R.id.tv_4, StringUtils.getCommaFormat(new BigDecimal(item.getAllocateNum())));
        ((TextView) helper.getView(R.id.tv_3)).setEllipsize(TextUtils.TruncateAt.END);
        ((TextView) helper.getView(R.id.tv_3)).setSingleLine(true);
    }
}
